package com.study.leetcode;

public class Solution_287 {
    public int findDuplicate(int[] nums) {
        int fast = 0;
        int slow = 0;
        int length = nums.length;
        while (nums[fast] != nums[slow]) {
            fast = (fast + 2) % length;
            slow = (slow + 1) % length;
        }
        return nums[slow];
    }
}
